Enable the inline preview of the slides. It generate a pdf with all the previous slides, and show the last one. So it can become pretty slow at some point.


In [140]:
inline_slides = False

In [141]:
import sys
import os
from IPython.display import Image
#sys.path.append('/Users/pire/git/Python4WindEnergy/slide_generator/')
from latex_generator.slides import *

### Don't forget to use 2 \\ if you want to have 1 \ in your .tex file!

s = slides(
  tex_filename= 'WP1_20140120_Rethore.tex',
  short_title = 'WP1',
  title = "Transfer of knowledge from WP1 to WP4 \\& WP5",
  date = 'Trondheim meeting \\\\ 21 January 2014',
  author= "Pierre-Elouan R\\'{e}thor\\'{e}*",
  short_author = "P.-E. R\\'{e}thor\\'{e}",
  institute = "Aero-elastic Section, Wind Energy Department, DTU, Ris\\o{}"
)

#f = lambda *args, **kwargs: s.f(*args, **kwargs)
def f(*args, **kwargs): 
    s.f(*args, **kwargs)
    if inline_slides:
        return show_last(s)
        
def show_last(s):
    s.compile()       
    ## Convert the pdf into png files
    commands.getoutput('rm single*png; /usr/local/bin/convert -density 100 ' + s.pdf_filename + ' single.png')
    ## Get the last slide image
    fis = filter(lambda x: x.find('png')>-1, os.listdir('.'))
    sl = sort(map(lambda x: int(x[x.find('-')+1:x.find('.png')]), fis))
    print 'single-%d.png'%(sl[-1])
    ## You might not want the retina option to be true, if you have a retarded computer.
    return Image(filename='single-%d.png'%(sl[-1]), retina=True)

Sections create a table of content slide each time you call them


In [142]:
s.section('Introduction')

show_last(s)


single-1.png
Out[142]:

Subsections appear as a main title in the frame, and the frame title is a subtitle. If you don't generate the slides in orders, the title might get fucked up because of the previous subsection defined in another cell.

The body of the slide can be formated with some very simple markdown itemization


In [143]:
s.subsection('Background')
f('Status',"""
* WP1 is finished
* We have benchmarked the different available methods to model wind farm clusters
* We haven't formally decided which methods should be used:
	We haven't focussed on the "user friendliness" 
	  (e.g. does the user have to be an expert, does the model run on 
	   a single PC, how long time does the model run)

""")

+ are creating boxes


In [144]:
f('T1.1 Wind farm scale wake models',"""
* All the benchmarks are finished. Kurt Hansen is presenting the Lillgrund results at Deepwind conference this week.
* The uncertainty quantification part is put on hold to follow the recommendations of WakeBench
* DTU has hired a new PhD student working on uncertainty quantification of wind farm flow models. 
  The outcome of the PhD work will be disseminated to EERA-DTOC and WakeBench.

+ WP1 -> WP4
	* Which microscale model to run?
	* How to run the microscale wake models?

+ WP1 -> WP5 
	* The LIDAR measurements
	* Roedsand 2 dataset
	* Running the scenarios
""")

In [145]:
a = random.random([5,3])
print a
print 

s.section('Some results')
s.subsection('Cluster stuff')
f('T1.2 Cluster scale wake models',["""
* The benchmarks have been formally reported.

* The satelite pictures have been identified and are being processed. 
  We should be able to have scenarios based on those measurements to test the models.

+ WP1 -> WP4
	* Which mesoscale model to run (WRF-DTU or WRF-Ciemat)?
	* How to run the mesoscale models? Which parameters etc..
""",
block(centered(table(a, xlabel=['a','b','c'], ylabel=['l0','l1','l2','l3','l4'])),
      title='Caption')
])


[[ 0.96789453  0.17483054  0.89258567]
 [ 0.6240565   0.79416063  0.59110962]
 [ 0.77938136  0.92496864  0.60427891]
 [ 0.0230522   0.99935151  0.70717905]
 [ 0.86030047  0.04803153  0.11276176]]

Let's generate a plot to include it in the following slide


In [146]:
x = linspace(0, 100)
y = sqrt(x)
plot(x,y)
savefig('myfig.pdf')


To add a centered figure, just use the cfig function inside the text. Note that the string in the body of the slide can also be a list of strings


In [147]:
f('T1.3 Coupling',["""

+ WP1 -> WP4
	* How to connect the wind farm scale wake models to the cluster scale wake models?
		* Which information is needed from the mircroscale models?
			* Thrust value of each wind turbine
		* Which information is needed from the mesoscale models?
			* A local wind resource estimate (e.g. wind rose) at each wind turbine position

""",
  cfig('myfig.pdf', width=u'0.5\\textwidth')]
  )

Let's make a retarded animation


In [148]:
x = linspace(0,4*pi,100)
for n in range(4):
    plot(x, sin(n*x))
    savefig('anim-%d.pdf'%(n))


You can make loops around frames, and add the images with the loop number. They won't show inline unfortunately.


In [149]:
for n in range(4):
    f('T1.3 Coupling',["""

+ WP1 -> WP4
	* How to connect the wind farm scale wake models to the cluster scale wake models?
		* Which information is needed from the mircroscale models?
			* Thrust value of each wind turbine
		* Which information is needed from the mesoscale models?
			* A local wind resource estimate (e.g. wind rose) at each wind turbine position

""",
  cfig('anim-%d.pdf'%(n), width=u'0.5\\textwidth')]
  )

You can have some columns as well


In [150]:
f('T1.3 Coupling',["""

+ WP1 -> WP4
	* How to connect the wind farm scale wake models to the cluster scale wake models?
		* Which information is needed from the mircroscale models?
			* Thrust value of each wind turbine
		* Which information is needed from the mesoscale models?
			* A local wind resource estimate (e.g. wind rose) at each wind turbine position
""", 
columns([
"""
+ WP1 -> WP5
	* Roedsand 2 dataset to validate the couple use of the tool
""",
cfig('myfig.pdf', width=u'\\textwidth')
])
]
)

At the end of the document you can compile the whole tex file and open the pdf. If you have run the cells several times, everything is going to be messed up. You should therefore only run this cell by doing a cell/run all to regenerate all the cells. Don't forget to desactivate the inline_slide to save some time.


In [152]:
s.compile()
commands.getoutput('open '+s.pdf_filename)


Out[152]:
''

In [151]: